package com.lys.conf;

import org.apache.zookeeper.ZooKeeper;
import org.junit.Before;
import org.junit.Test;

public class TestConfig {

    private ZooKeeper zooKeeper;

    @Before
    public void before(){
        zooKeeper = ZookeeperUtil.getZooKeeper();
    }



    @Test
    public void run(){
        CallbackWatcher callbackWatcher = new CallbackWatcher();
        callbackWatcher.setZooKeeper(zooKeeper);
        callbackWatcher.initConfig("/testConfig");
        while(true){
            MyConfig myConfig = callbackWatcher.getMyConfig();
            if (myConfig==null){
                callbackWatcher.initConfig("/testConfig");
            }else {
                System.out.println(myConfig);
            }
            try {
                Thread.sleep(1000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
